home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
Palettes
/
TTools
/
TToolsPalette
/
TBinderList.subproj
/
TConnector.m
< prev
next >
Wrap
Text File
|
1995-06-12
|
3KB
|
121 lines
/* TConnector.m
* Written By: Thomas Burkholder
*
* You may freely copy, distribute, and reuse the code in this example.
* NeXT disclaims any warranty of any kind, expressed or implied, as to its
* fitness for any particular use.
*/
#import <apps/InterfaceBuilder.h>
#import "TConnector.h"
#import "TBinder.h"
#import "TBinderList.h"
#import "../ListEditor.subproj/ListEditor.h"
@implementation TConnector
- init
{
[super init];
binder = nil;
return self;
}
- free
{
[binder free];
return [super free];
}
- setBinder:anObject andSource:anotherObject
{
binder = anObject;
source = anotherObject;
return self;
}
- binder
{
return binder;
}
- source
{
return source;
}
- destination
{
return [binder interface];
}
- establishConnection
{
return self;
}
- forgeConnection:sender
{
id face = [binder interface];
if ([face respondsTo:@selector(setTarget:)] &&
[face respondsTo:@selector(setAction:)] &&
[face respondsTo:@selector(target)] &&
[face respondsTo:@selector(action)]) {
// preserve target/action stuff...
[binder setTarget:[face target]];
[binder setAction:[face action]];
[face setTarget:binder];
[face setAction:@selector(updateDataSource:)];
}
return self;
}
- nibInstantiate
{
// add ourselves to TBinderList... alternative is to keep the binder
// in the list the whole time anyway, but this makes the connection
// stuff confusing, particularly when IB sees fit to free a connection
// holding a binder - the free method for TConnector then has to do
// gnarly stuff to make sure the editor knows about the deletion, and
// then you have to put a conditional in in case you're in testInterface
// ... it just gets worse from there. So we don't edit the TBinderList,
// which is probably just as well.
[binder setDataSource:[source dataSource]];
[source addObject:binder];
// need to do the autoupdate stuff as well.
// need to delay it so that TestInterface doesn't take over the
// interface's target/actions.
if ([binder autoUpdate])
[self perform:@selector(forgeConnection:) with:self afterDelay:0
cancelPrevious:NO];
return self;
}
- renewObject:old to:new
{
if (old == source)
source = new;
else if (old == [binder interface])
[binder setInterface:new];
return self;
}
- read:(NXTypedStream *)stream
{
[super read:stream];
binder = NXReadObject(stream);
source = NXReadObject(stream);
return self;
}
- write:(NXTypedStream *)stream
{
[super write:stream];
NXWriteObject(stream,binder);
NXWriteObject(stream,source);
return self;
}
@end